#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/12/9 0:47
# @Author  : lizhen
# @Site    : 
# @File    : sequence.py
# @Software: PyCharm
from collections import namedtuple, Sequence


class CustomSequence(Sequence):
    Cards = namedtuple('Cards', ['rank', 'suit'])
    ranks = [item for item in range(2, 11)] + list('JQKA')
    suits = 'spades diamonds clubs hearts'.split()

    def __init__(self):
        self._cards = [self.Cards(rank, suit) for rank in self.ranks for suit in self.suits]

    def __len__(self):
        return len(self._cards)

    def __getitem__(self, item):
        return self._cards[item]


def main():
    cs = CustomSequence()
    print(len(cs))
    print(cs[0])


if __name__ == '__main__':
    main()
